from ..main import app
from django.core.mail import send_mail
from mall import settings


@app.task(name='send_verify_mail')
def send_verify_mail(email, url):
    # subject, message, from_email, recipient_list,html_message=None
    subject = '美多商城激活邮件'
    message = ''
    from_email = settings.EMAIL_FROM  # 发件人
    recipient_list = [email]  # 收件人列表
    # 可以传递 html代码
    # 我们需要生成一个url,这个url中的token需要包含用户的id信息(id需要被处理)
    html_message = '<p>尊敬的用户您好！</p>' \
                   '<p>感谢您使用美多商城。</p>' \
                   '<p>您的邮箱为：%s 。请点击此链接激活您的邮箱：</p>' \
                   '<p><a href="%s">%s<a></p>' % (email, url, url)
    send_mail(subject, message, from_email, recipient_list, html_message=html_message)
